﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using System.Data;

namespace RBAC
{
    public class NodeOperation
    {
        /// <summary>
        /// 针对结点操作类
        /// 
        /// </summary>
        public NodeOperation()
        { }

        #region 结点类别处理方法
        /// <summary>
        /// 添加一个结点类别
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool AddNodeGroup(Model.NodeGroup model)
        {
            return true;
        }
        /// <summary>
        /// 获取一个结点类别信息
        /// </summary>
        /// <param name="ngid">NodeGroup主键ID</param>
        /// <returns></returns>
        public static Model.NodeGroup GetNGModel(int ngid)
        {
            Model.NodeGroup model = new RBAC.Model.NodeGroup();
            return model;
        }
        public static DataSet GetNGList(string strWhere)
        {
            DataSet ds = new DataSet();
            return ds;
        }
        /// <summary>
        /// 传入类别ID，获取结点组
        /// </summary>
        /// <param name="ngid">NodeGroup主键ID</param>
        /// <returns></returns>
        public static DataSet GetNodeList(int ngid)
        {
            DataSet ds = new DataSet();
            return ds;
        }
        #endregion

        #region 结点信息处理方法
        /// <summary>
        /// 添加一个结点信息
        /// </summary>
        /// <param name="model">结点属性</param>
        /// <returns></returns>
        public static bool AddNode(Model.Node model)
        {
            return true;
        }
        /// <summary>
        /// 添加多个结点信息
        /// </summary>
        /// <param name="models">L</param>
        public static void AddNode(IList<Model.Node> models)
        { }
        
        /// <summary>
        /// 更新一个结点信息
        /// </summary>
        /// <param name="model"></param>
        /// <param name="nid"></param>
        /// <returns></returns>
        public static bool UpdateNode(Model.Node model,int nid)
        {
            return true;
        }
        /// <summary>
        /// 更新一个结点信息，带参。
        /// </summary>
        /// <param name="nid">结点ID</param>
        /// <param name="strSql">SQL语句</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public static bool UpdateNode(int nid,string strSql,SqlParameter[] parameters)
        {
            return true;
        }
        /// <summary>
        /// 更新多条数据，带参，返回
        /// </summary>
        /// <param name="nids">结点ID</param>
        /// <param name="strSql">SQL语句</param>
        /// <param name="parameters">参数组</param>
        /// <param name="mistakeId">out型int变量，返回更新失败的结点ID</param>
        /// <returns></returns>
        public static bool UpdateNode(List<int> nids,string strSql,SqlParameter[] parameters,out int mistakeId)
        {
            mistakeId = -1;
            return true;
        }
        #endregion

        #region 结点与角色关系处理方法
        /// <summary>
        /// 给结点添加一个角色信息
        /// </summary>
        /// <param name="nid">结点ID</param>
        /// <param name="rid">角色ID</param>
        /// <returns></returns>
        public static bool AddRole(int nid,int rid)
        {
            return true;
        }
        /// <summary>
        /// 给指定结点添加多个角色
        /// </summary>
        /// <param name="nid">结点ID</param>
        /// <param name="rids">角色ID集</param>
        public static bool AddRole(int nid,List<int> rids)
        {
            return true;
        }
        /// <summary>
        /// 删除指定结点的一个角色
        /// </summary>
        /// <param name="nid">结点ID</param>
        /// <param name="rid">角色ID</param>
        /// <returns></returns>
        public static bool DeleteRole(int nid,int rid)
        {
            return true;
        }
        /// <summary>
        /// 删除指定结点的多个角色
        /// </summary>
        /// <param name="nid"></param>
        /// <param name="rids"></param>
        /// <returns></returns>
        public static bool DeleteRole(int nid, List<int> rids,out int mistakeId)
        {
            mistakeId = -1;
            return true;
        }

        /// <summary>
        /// 更新某一节点的角色信息
        /// </summary>
        /// <param name="model"></param>
        /// <param name="nid">结点ID</param>
        /// <returns></returns>
        public static bool UpdateRole(Model.Access model,int nid)
        {
            return true;
        }
        /// <summary>
        /// 更新多条结点
        /// </summary>
        /// <param name="nids">结点ID集</param>
        /// <param name="strSql">SQL语句</param>
        /// <param name="parameters">参数集</param>
        /// <param name="mistakeId">out型int,</param>
        /// <returns></returns>
        public static bool UpdateRole(List<int> nids,string strSql,SqlParameter[] parameters,out int mistakeId)
        {
            mistakeId = -1;
            return true;
        }
        /// <summary>
        /// 获取某结点的所有角色信息
        /// </summary>
        /// <param name="nid">结点ID</param>
        /// <returns>DataSet</returns>
        public static DataSet GetNodeRoleAllList(int nid)
        {
            DataSet ds = new DataSet();
            return ds;
        }

        #endregion
    }
}
